<template>
  <div class="tab-item" :class="{
    active: cityInfo.cityId === cityId
  }"
  @click="changeCityInfo"
  >
    <span>{{ cityInfo.cityName }}</span>
  </div>
</template>

<script>
import {mapState} from 'vuex'
export default {
  name: 'TabItem',
  props: {
    cityInfo: Object,
  },
  computed: {
    ...mapState(['cityId'])
  },
  methods: {
    changeCityInfo () {
      this.$store.commit('selectCity', this.cityInfo)
    }
  }
}
</script>

<style lang="scss" scoped>
.tab-item {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  height: .4rem;
  background-color: #fff;
  border-bottom: 2px solid #fff;
  &.active {
    border-color: aqua;
    color: aqua;
  }
  span {
    font-size: .16rem;
  }
}
</style>